<?php
/*
|------------------------------------------------------------------|
|	Level5 - Wordpress Theme Framework
|
|	Copyright (c) Brixter de Leon
|	http://frostproject.org
|	deleon.brixter@gmail.com
|
|	This program is free software; you can redistribute it and/or
|	modify it under the terms of the GNU General Public License
|	as published by the Free Software Foundation; either version 2
|	of the License, or (at your option) any later version.
|
|	This program is distributed in the hope that it will be useful,
|	but WITHOUT ANY WARRANTY; without even the implied warranty of
|	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
|	GNU General Public License for more details.
|
|	You should have received a copy of the GNU General Public License
|	along with this program; if not, write to the Free Software
|	Foundation, Inc., 51 Franklin Street, Fifth Floor, 
|	Boston, MA  02110-1301, USA.
|------------------------------------------------------------------|
*/

/** Wordpress admin panel configuration file for level5. Do not edit this file. */

/** Check current logged user status */
if ( ! current_user_can( 'manage_options' ) )
{
	if( $_GET['page'] == 'admin.php' )
	{
		wp_die( 'You do not have sufficient permissions to access this page.' );
	}
}

/** Initialize jQuery support. */
wp_enqueue_script( 'jquery' );

/** Fetch information of currently logged in user. */
get_currentuserinfo();

/** Prevent direct access to core system files. */
define( 'direct_access', true );

/** Define level5' configuration variables. */
define( 'level5_framename', 'Level5' );
define( 'level5_frameprefix', 'level5_' );
define( 'level5_framever', 'v2 alpha' );
define( 'level5_frameurl', 'http://frostproject.org' );
define( 'level5_themedefault', '_default' );

/** Define level5 script path. */
define( 'level5_scriptpath', dirname(__FILE__) . '/' );
define( 'level5_source', level5_scriptpath . 'source/' );

/** Define additional path. */
define( 'level5_library', level5_source . 'library/' );
define( 'level5_source_url', 'source/' );
define( 'level5_child', level5_scriptpath . 'child/' );
define( 'level5_child_url', 'child/' );
define( 'level5_files', level5_source . 'files/' );
define( 'level5_files_url', 'files/' );
define( 'level5_images', level5_source . 'images/' );
define( 'level5_images_url', 'images/' );
define( 'level5_wordpress_lib', ABSPATH . 'wp-admin/includes/' );
define( 'level5_wp_theme_url', get_bloginfo( 'template_url' ) . '/' );

/** Core files */
include_once( level5_library . 'general-function.php' );
include_once( level5_library . 'loader.php' );
include_once( level5_wordpress_lib . 'class-pclzip.php' );
if ( file_exists( level5_child . level5_template . '/functions.php' ) )
{
	include_once( level5_child . level5_template . '/functions.php' );
}
include_once( level5_library . 'options.php' );
if ( file_exists( level5_child . level5_template . '/loader.php' ) )
{
	include_once( level5_child . level5_template . '/loader.php' ); // Default theme option variables
}
define( 'level5_files_custom_css_url', level5_wp_theme_url . level5_source_url . level5_files_url ); // This is used to fetch child theme's custom stylesheet.
define( 'level5_template_url', level5_wp_theme_url . level5_child_url . level5_sanitize( level5_template, 'theme_name' ) );
define( 'level5_template_path', level5_child . level5_template );

/** Admin pages. */
define( 'level5_page1', 'General options' );
define( 'level5_page2', $level5_theme_info['name'] );
define( 'level5_page3', 'Widgets' );
define( 'level5_page4', 'About ' . level5_framename );
define( 'level5_page5', 'Upload a theme' );
define( 'level5_page6', 'Themes' );

/** Fetch the theme option based on page */
if ( $_GET['page'] == level5_sanitize( level5_page1 ) )
{
	level5_attributes( 'general' );
}
elseif ( $_GET['page'] == level5_sanitize( level5_page2 ) )
{
	level5_attributes( 'child' );
}
elseif ( $_GET['page'] == level5_sanitize( level5_page6 ) )
{
	level5_attributes( 'themes' );
}

/** Load admin theme files. */
function level5_general()
{
	global $settings, $value;
	require_once( level5_library . '/template.php' );
}
function level5_themes()
{
	global $settings, $value, $level5_theme_info;
	level5_attributes( 'themes' );
	require_once( level5_library . '/template.php' );
}
function level5_child()
{
	global $settings, $value;
	require_once( level5_library . '/template.php' );
}
function level5_about()
{
	global $settings, $value;
	level5_attributes( 'about' );
	require_once( level5_library . '/template.php' );
}
function level5_upload()
{
	global $settings, $value;
	level5_attributes( 'upload' );
	require_once( level5_library . '/template.php' );
}
function level5_widget()
{
	//require_once( level5_library . '/template.php' );
	header( 'Location: widgets.php' );
}

/** Fetch the level5' hook. */
add_action( 'admin_menu', 'level5_process' );
add_action( 'admin_head', 'level5_default_css' );
add_filter( 'level5_search_form', 'level5_search_form' );

if ( function_exists( 'level5_register_sidebar' ) )
{
	level5_register_sidebar();
}
?>